<template>
    <div id="tmpl">
        <ul class="mui-table-view">
            <li v-for="item in list" class="mui-table-view-cell mui-media">
                <router-link v-bind="{to:'/news/newsinfo/'+ item.id}">
                    <img class="mui-media-object mui-pull-left" :src="item.img_url">
                    <div class="mui-media-body">
                        {{item.title}}
                        <p class="mui-ellipsis" v-text="item.zhaiyao"></p>
                        <span>时间：{{item.add_time | datefmt('YYYY-MM-DD HH:mm:ss') }}</span>
                        <span>点击数：{{item.click}}</span>
                    </div>
                </router-link>
            </li>
        </ul>
    </div>
</template>

<script>
import { Toast } from 'mint-ui';
import common from '../../kits/common.js';
export default {
    data(){
        return {
            list:[]
        }
    },
    created(){
        this.getlist();
    },
    methods:{
        getlist(){
            var url = common.apiurl + '/api/newslist.php';
            this.$http.get(url).then(function(res){
                var data = res.body;
                //错误处理
                if(data.status != 0){
                    Toast(data.message);
                    return;
                }
                //数据正常处理
                this.list = data.message;
            })
        }
    }
}

</script>

<style scoped>
    .mui-table-view .mui-media-object.mui-pull-left {
        margin-right: 15px;
    }
    .mui-table-view .mui-media-object {
        line-height: 63px;
        max-width: 63px;
        height: 63px;
    }
    .mui-media-body span{
        font-size:12px;
        color:#999;
        margin-right: 1rem;
    }
    .mui-table-view-cell p{
        margin-top: 0.2rem;
        color:#666;
    }
    .mui-media-body{
        text-overflow: ellipsis;
    }
</style>